package com.jvm;

import sun.misc.Launcher;
import sun.misc.URLClassPath;

import java.net.URL;
import java.net.URLClassLoader;

/**
 * 类加载器
 * 1.类加载器的种类
 * 2.双亲委派机制，what   how，
 * 这种双亲委派模式的好处，一个可以避免类的重复加载，另外也避免了java的核心API被篡改。
 */
public class ClassLoaderTest {
    public static void main(String[] args) {
        URLClassPath path = Launcher.getBootstrapClassPath();
        System.out.println(Launcher.class.getClassLoader());
        for(URL url : path.getURLs()){
            System.out.println(url.getPath());
        }

        System.out.println("----------------------------------");
        URLClassLoader extClassLoader = (URLClassLoader)ClassLoader.getSystemClassLoader().getParent();
        System.out.println(ClassLoader.getSystemClassLoader().getParent());
        for(URL url : extClassLoader.getURLs()) {
            System.out.println(url.getPath());
        }
    }
}
